<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AddWgNumberStatusToMapNationalBrandShopTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('map_national_brand_shop', function (Blueprint $table) {
            $table->unsignedInteger('type')->default(0)->after('name')->comment('品牌类型   1-竞品  2-互补品');
            $table->double('status', 2)->default(0)->after('name')->comment('点位状态');
            $table->string('wgNumber', 32)->default('')->after('name')->comment('网规编号');
        });
        \Illuminate\Support\Facades\DB::statement("UPDATE `map_national_brand_shop` SET wgNumber = CONCAT('PP77', RIGHT(CONCAT(REPEAT('0', 7), CAST(`id` AS CHAR(7))), 7))");
        \Illuminate\Support\Facades\DB::statement("update `map_national_brand_shop` set `type` = '1' where `brand` in ('正新鸡排', '华莱士', '阿甘锅盔', '煌上煌', '久久丫', '绝味鸭脖', '赛百味', '喜姐炸串', '周黑鸭')");
        \Illuminate\Support\Facades\DB::statement("update `map_national_brand_shop` set `type` = '2' where `brand` in ('茶百道', '古茗', '蜜雪冰城', '七分甜', '书亦烧仙草', '幸运咖', '一只酸奶牛', '悦刻', 'Coco奶茶')");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('map_national_brand_shop', function (Blueprint $table) {
            $table->dropColumn('type');
            $table->dropColumn('wgNumber');
            $table->dropColumn('status');
        });
    }
}
